// Copyright 2009 Pigasus.
// GNU GPL v2.
// Author: John Zhang and Jordan Rupprecht.
//
// Defines the function needed by the <string> % <list> operator (i.e.
// equivalent to the Python % operator).
//
// User should call FormatString(), never PrintChunk().

#ifndef FORMATSTRING_H_
#define FORMATSTRING_H_

#include <string>

#include "pigasus-types.h"

using namespace std;

// Applies sprintf() to fmt using arg, where fmt is a format string that is
// known to contain exactly one format specifier (it may be %%). Also send in a
// flag arg_used, which will be set to 1 if arg is actually used (i.e. %% is not
// in fmt) or 0 otherwise.
string PrintChunk(string fmt, void *arg, string type, int *arg_used);

// Applies <fmt> % <args>, or similar to printf(fmt, args). 
string FormatString(string fmt, const List &arg);

#endif  // FORMATSTRING_H_
